package game.roles.bullets;

import game.frame.MainFrame;
import game.roles.Role;
import game.roles.enemys.Bosses;
import game.roles.enemys.EnemyRole;
import game.roles.visual.Blast;
import game.utils.ImageChange;

import java.awt.*;
import java.util.Random;

/**
 * @author liuyulai
 * Created with IntelliJ IDEA.
 * Date: 21.5.10
 * Time: 11:24
 * Description: 友军坦克类
 */
public class FriendlyTank extends Role implements GamerBullet {
    public static Image[] friendlyTankImage;

    private ImageChange rm = new ImageChange(3);

    public FriendlyTank(int y) {
        super(-100, y - 100, 200, 200);
    }

    @Override
    public void rolesMove() {
        this.x += 10;
        this.img = rm.change(friendlyTankImage);
        for (int i = 0; i < MainFrame.roleList.size(); i++) {
            Role r = MainFrame.roleList.get(i);
            if (r instanceof EnemyRole && this.rec.intersects(r.rec)) {
                EnemyRole s1 = (EnemyRole) r;
                s1.byHit(500);
                MainFrame.roleList.add(new Blast(this.x, this.y));
                if (r instanceof Bosses) {
                    MainFrame.roleList.remove(this);
                }
                return;
            } else if (r instanceof EnemyBullet && this.rec.intersects(r.rec)) {
                MainFrame.roleList.remove(r);
                MainFrame.roleList.add(new Blast(this.x, this.y));
                i--;
            }
        }
    }

}
